package com.hongye.config;

import com.hongye.app.controller.AppOrderController;
import com.hongye.app.controller.Cron4jPlugin;
import com.hongye.app.controller.UserAppInfoController;
import com.hongye.app.controller.UserShopController;
import com.hongye.app.model.AppVersionModel;
import com.hongye.app.model.AuthorModel;
import com.hongye.app.model.BuyerAddressModel;
import com.hongye.app.model.BuyerAlipayModel;
import com.hongye.app.model.BuyerStatisticsModel;
import com.hongye.app.model.ContentModel;
import com.hongye.app.model.EmployeeManageModel;
import com.hongye.app.model.EvaluationModel;
import com.hongye.app.model.ExpressModel;
import com.hongye.app.model.FavoriteModel;
import com.hongye.app.model.FeedBackModel;
import com.hongye.app.model.GoodsCategroyModel;
import com.hongye.app.model.GoodsDataModel;
import com.hongye.app.model.GoodsModel;
import com.hongye.app.model.MenuModel;
import com.hongye.app.model.NewRegionModel;
import com.hongye.app.model.OrderGoodsModel;
import com.hongye.app.model.OrderInfoModel;
import com.hongye.app.model.OrderTracesModel;
import com.hongye.app.model.PaymentModel;
import com.hongye.app.model.PhoneCodeModel;
import com.hongye.app.model.Real_nameModel;
import com.hongye.app.model.ReturnGoodsModel;
import com.hongye.app.model.RoleModel;
import com.hongye.app.model.ShoppingCartModel;
import com.hongye.app.model.TakeOutModel;
import com.hongye.app.model.UserAppModel;
import com.hongye.app.model.ViewDetailModel;
import com.hongye.controller.AlipayController;
import com.hongye.controller.ContentController;
import com.hongye.controller.EmployeeManageController;
import com.hongye.controller.FeedBackController;
import com.hongye.controller.GoodsController;
import com.hongye.controller.KdniaoController;
import com.hongye.controller.OrderController;
import com.hongye.controller.PaymentController;
import com.hongye.controller.Real_nameController;
import com.hongye.controller.ReturnGoodsController;
import com.hongye.controller.TakeoutController;
import com.hongye.controller.TestController;
import com.hongye.controller.UserController;
import com.hongye.controller.VersionController;
import com.hongye.controller.WeixinController;
import com.hongye.interceptor.AuthInterceptor;
import com.hongye.model.AdminUser;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.render.ViewType;

public class SysConfig extends JFinalConfig {

	public SysConfig() {
	}

	@Override
	public void configConstant(Constants me) {
		me.setDevMode(PropKit.use("setting.properties").getBoolean("devMode"));
		me.setViewType(ViewType.JSP);
	}

	@Override
	public void configRoute(Routes me) {
		me.add("/admin",UserController.class,"admin");
		me.add("/test",TestController.class,"admin");
		me.add("/app", UserAppInfoController.class,"/app");
		me.add("/returngoods", ReturnGoodsController.class,"/app");
		me.add("/goods",GoodsController.class,"admin");
		me.add("/order",OrderController.class,"admin");
		me.add("/kdniao",KdniaoController.class,"admin");
		me.add("/alipay",AlipayController.class,"admin");
		me.add("/payment",PaymentController.class,"admin");
		me.add("/weixin",WeixinController.class,"admin");
		me.add("/shop",UserShopController.class,"/app");
		me.add("/feedback",FeedBackController.class,"/admin");
		me.add("/employee",EmployeeManageController.class,"/admin");
		me.add("/apporder",AppOrderController.class,"/app");
		me.add("/version",VersionController.class,"/admin");
		me.add("/content",ContentController.class,"/admin");
		me.add("/takeout",TakeoutController.class,"/admin");
		me.add("/realname",Real_nameController.class,"/admin");
	}

	@Override
	public void configPlugin(Plugins me) {
		// 配置Cron4jPlugin插件
		me.add(new Cron4jPlugin());
		this.loadPropertyFile("jdbc.properties");
//		数据库连接池
		DruidPlugin dp=new DruidPlugin(getProperty("jdbcUrl"), getProperty("username"), getProperty("passwd"));
		me.add(dp);
		ActiveRecordPlugin arp=new ActiveRecordPlugin(dp);
		me.add(arp);
		arp.addMapping("admin",AdminUser.class);
		arp.addMapping("buyer","user_id", UserAppModel.class);
		arp.addMapping("goods", GoodsModel.class);
		arp.addMapping("goods_data", GoodsDataModel.class);
		arp.addMapping("evaluation", EvaluationModel.class);
		arp.addMapping("buyer_address", BuyerAddressModel.class);
		arp.addMapping("phone_code", PhoneCodeModel.class);
		arp.addMapping("order_info", OrderInfoModel.class);
		arp.addMapping("order_goods", OrderGoodsModel.class);
		arp.addMapping("return_g","return_id", ReturnGoodsModel.class);
		arp.addMapping("newregion", NewRegionModel.class);
		arp.addMapping("goods_categroy", GoodsCategroyModel.class);
		arp.addMapping("shoppingcart", ShoppingCartModel.class);
		arp.addMapping("favorite", FavoriteModel.class);
		arp.addMapping("role", RoleModel.class);
		arp.addMapping("auth", AuthorModel.class);
		arp.addMapping("menu", MenuModel.class);
		arp.addMapping("order_traces", OrderTracesModel.class);
		arp.addMapping("express", ExpressModel.class);
		arp.addMapping("buyer_alipay", BuyerAlipayModel.class);
		arp.addMapping("buyer_statistics", BuyerStatisticsModel.class);
		arp.addMapping("payment", PaymentModel.class);
		arp.addMapping("viewdetail", ViewDetailModel.class);
		arp.addMapping("feedback", FeedBackModel.class);
		arp.addMapping("employee_manage", "e_id", EmployeeManageModel.class);
		arp.addMapping("version", AppVersionModel.class);
		arp.addMapping("content", ContentModel.class);
		arp.addMapping("takeout", TakeOutModel.class);
		arp.addMapping("real_name", Real_nameModel.class);
//		arp.addMapping("sysparam",SysParam.class);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		me.addGlobalActionInterceptor(new AuthInterceptor());
	}

	@Override
	public void configHandler(Handlers me) {
	}

}
